package rpc.provider.consumer.third;

import rpc.provider.consumer.RpcException;
import rpc.provider.consumer.SoaErrorEnum;
import rpc.provider.consumer.SoaResponse;
import rpc.provider.consumer.provider.UserQueryProvider;

import java.util.Objects;

/**
 * @author: cuiyutian1
 * @date: 2021/9/4 13:31
 * @description:
 */
public class UserQueryThirdService {

    public SoaResponse<String> UserQuery() {
        SoaResponse<String> response = null;
        try {
            UserQueryProvider provider = new UserQueryProvider();
            response = provider.userQuery();
        }catch (RpcException e) {
            response.setCode(SoaErrorEnum.ERROR);
            response.setErrorMsg(SoaErrorEnum.ERROR);
        }catch (Exception e) {
            response.setErrorMsg(SoaErrorEnum.SYSTEM_ERROR);
            response.setErrorMsg(e.getMessage());
        }
        if(SoaErrorEnum.SUCCESS.getCode().equals(response.getCode()) && Objects.nonNull(response.getData())){
            response.setErrorMsg(SoaErrorEnum.SUCCESS);
        }
        return response;
    }
}
